package cn.byapps.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@Entity
@JsonInclude(Include.NON_NULL)
//将该标记放在属性上，如果该属性为NULL则不参与序列化
//如果放在类上边,那对这个类的全部属性起作用
//Include.Include.ALWAYS 默认
//Include.NON_DEFAULT 属性为默认值不序列化
//Include.NON_EMPTY 属性为 空（“”） 或者为 NULL 都不序列化
//Include.NON_NULL 属性为NULL 不序列化 
//注意：只对VO起作用，Map List不起作用
public class User implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue
	private Integer id;

	@Override
	public String toString() {
		return "User [id=" + id + ", telphone=" + telephone + ", name=" + name + ", sex=" + sex + ", coupleName="
				+ coupleName + ", coupleId=" + coupleId + ", pwd=" + pwd + ", msg=" + msg + ", parent=" + parent
				+ ", children=" + children + "]";
	}

	@Column(length = 20)
	private String loginName;

	@Column(length = 20)
	private String telephone;

	@Column(length = 20)
	private String name;

	@Column(length = 10)
	private String sex;

	@Column(length = 20)
	private String coupleName;

	private Integer coupleId;

	@JsonIgnore
	@Column(length = 50)
	private String pwd;

	@Column(length = 200)
	private String msg;

	@JsonIgnore
	@ManyToOne
	@JoinColumn(name = "parentId")
	private User parent;

	@OneToMany(mappedBy = "parent")
	@OrderBy("id ASC")
	private Set<User> children = new HashSet<User>();
	@JsonIgnore
	@OneToMany(mappedBy = "user")
	// @OrderBy("id ASC")
	private Set<UploadFile> files = new HashSet<UploadFile>();

	private Integer valid = 1;

	public Integer getValid() {
		return valid;
	}

	public void setValid(Integer valid) {
		this.valid = valid;
	}

	public Set<UploadFile> getFiles() {
		return files;
	}

	public void setFiles(Set<UploadFile> files) {
		this.files = files;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public User getParent() {
		return parent;
	}

	public void setParent(User parent) {
		this.parent = parent;
	}

	public Set<User> getChildren() {
		return children;
	}

	public void setChildren(Set<User> children) {
		this.children = children;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getCoupleName() {
		return coupleName;
	}

	public void setCoupleName(String coupleName) {
		this.coupleName = coupleName;
	}

	public Integer getCoupleId() {
		return coupleId;
	}

	public void setCoupleId(Integer coupleId) {
		this.coupleId = coupleId;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
}
